var a = require("../../../utils/api.js"), t = getApp();

Page({
    data: {
        curcat: 0,
        page: 2,
        none: "none",
        showLoding: !0
    },
    onLoad: function(o) {
        var n = this;
        n.setData({
            showLoding: !n.data.showLoding
        }), wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        }), a.getFraction_index({
            openid: t.globalData.openid
        }).then(function(a) {
            console.log(a.data), n.setData({
                showLoding: !n.data.showLoding
            }), wx.stopPullDownRefresh(), 0 == a.data.status && n.setData({
                info: a.data.data,
                data: a.data.data.list,
                none: "block",
                curcat: 0
            });
        });
    },
    shuoming: function() {
        wx.navigateTo({
            url: "/pages/integralMall/shuoming/index"
        });
    },
    detail: function() {
        wx.navigateTo({
            url: "/pages/integralMall/detail/index"
        });
    },
    exchange: function() {
        wx.navigateTo({
            url: "/pages/integralMall/order/order"
        });
    },
    goodsInfo: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/pages/integralMall/goodsInfo/index?id=" + t
        });
    },
    order: function(a) {
        console.log(a.currentTarget.dataset.id);
    },
    catGoods: function(o) {
        var n = this, e = o.currentTarget.dataset.id;
        this.setData({
            curcat: e
        }), 0 != e ? a.getFraction_shop_list({
            pid: e
        }).then(function(a) {
            0 == a.data.status && n.setData({
                data: a.data.data,
                page: 2
            });
        }) : a.getFraction_index({
            openid: t.globalData.openid
        }).then(function(a) {
            0 == a.data.status && n.setData({
                data: a.data.data.list,
                page: 2
            });
        });
    },
    onPullDownRefresh: function(a) {
        this.onLoad();
    },
    onReachBottom: function(o) {
        wx.showLoading({
            title: "努力加载中"
        });
        var n = this, e = parseInt(n.data.page) + parseInt(1);
        0 != n.data.curcat ? a.getFraction_shop_list({
            pid: n.data.curcat,
            page: n.data.page
        }).then(function(a) {
            if (0 == a.data.status) {
                var t = n.data.data;
                t = t.concat(a.data.data), n.setData({
                    data: t,
                    page: e
                }), wx.hideLoading();
            }
        }) : a.getFraction_index({
            openid: t.globalData.openid,
            page: n.data.page
        }).then(function(a) {
            if (0 == a.data.status) {
                var t = n.data.data;
                t = t.concat(a.data.data.list), n.setData({
                    data: t,
                    page: e
                }), wx.hideLoading();
            }
        });
    },
    toH5: function(a) {
        var t = this, o = a.currentTarget.dataset.url;
        t.setData({
            url: o
        }), wx.navigateTo({
            url: "/pages/template/out_h5"
        });
    }
});